//
//  MainOneCheckView.m
//  XidouNetTool
//
//  Created by 喜豆 on 2018/8/14.
//  Copyright © 2018年 seedo. All rights reserved.
//

#import "MainOneCheckView.h"
#import "HeaderModel.h"
#import "BodyModel.h"

@implementation MainOneCheckView

-(void)setFrame:(NSRect)frame{
    [super setFrame:frame];
    CGFloat height = CGRectGetHeight(frame);
    self.md5Button.frame = CGRectMake(10, (height - 30) / 2, 100, 30);
    self.rememberButton.frame = CGRectMake(CGRectGetWidth(self.md5Button.frame) + 10, CGRectGetMidY(self.md5Button.frame), 100, 30);
}

-(NSButton *)rememberButton{
    if (!_rememberButton) {
        _rememberButton = [NSButton buttonWithTitle:@"Remember" target:self action:@selector(rememberAction)];
        [_rememberButton setButtonType:(NSButtonTypeOnOff)];
    }
    return _rememberButton;
}

-(NSButton *)md5Button{
    if (!_md5Button) {
        _md5Button = [NSButton buttonWithTitle:@"MD5" target:self action:@selector(md5Action)];
        [_md5Button setButtonType:(NSButtonTypeOnOff)];
    }
    return _md5Button;
}

-(void)setViewWithModel:(FieldBaseModel *) model{
    self.rememberButton.state = model.remember?NSOnState:NSOffState;
    if ([model isKindOfClass:[HeaderModel class]]) {
        self.md5Button.hidden = NO;
    }
    if([model isKindOfClass:[BodyModel class]]){
        BodyModel * bModel = (BodyModel *)model;
        self.md5Button.hidden = YES;
        self.md5Button.state = bModel.md5?NSOnState:NSOffState;
    }
}

#pragma mark - Actions

-(void)rememberAction{
    
}

-(void)md5Action{
    
}

@end
